{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Configuration of 4G EPC of Open Air Interface (OAI) with eNB in Docker and UE simuled with rfsim\n",
    "---\n",
    "### Objectives\n",
    "- Configure UE with rfsim 📱\n",
    "\n",
    "⚠️ **Attention:** To carry out this tutorial, you must already have the `EPC` and an `eNB` running. If you have any questions, check out the document [OAI eNB dashboard](https://github.com/vicentesousa/PPGEEC_2333/blob/main/howtos/H04_4G_EPC_Docker_UNI_III.ipynb)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4G EPC + eNB in Docker and UE simuled with rfsim\n",
    "\n",
    "---\n",
    "\n",
    "At the end of the H04_4G_EPC_UNI_III hands-on (this is the second one), the objective is to run the OAI simulated scenario, which consists of the 4G core (EPC), eNB in Docker and user equipment (UE) with rfsim, as shown in the image below:\n",
    "\n",
    "![UE_rfsim_config_](../FIGS/H04_4G_EPC_UNI_III/4G_EPC_deploy_UE_rfsim.png)\n",
    "\n",
    "---\n",
    "\n",
    "#### Step 1: \n",
    "Make a copy of the configuration file used to connect the UE: \n",
    "\n",
    "```bash\n",
    "cd /home/dco1020/openairinterface5g/openair3/NAS/TOOLS/\n",
    "cp ue_eurecom_test_sfr.conf ue_eurecom_test_sfr_original.conf\n",
    "rm -rf ue_eurecom_test_sfr.conf\n",
    "vi ue_eurecom_test_sfr.conf\n",
    "```\n",
    "\n",
    "After copying we will have the following files\n",
    "![UE_ue_eurecom_test_sfr_config_](../FIGS/H04_4G_EPC_UNI_III/4G_EPC_CP_ue_eurecom_test_sfr.png)\n",
    "\n",
    "⚠️ **Attention:** You must change the file name, in the example above `ue_eurecom_test_sfr.conf`.\n",
    "\n",
    "---\n",
    "\n",
    "####  Step 2: \n",
    "Change UE parameters\n",
    "\n",
    "In this step you need to edit the `ue_eurecom_test_sfr.conf` file as follows\n",
    "\n",
    "---\n",
    "\n",
    "```bash\n",
    "# List of known PLMNS\n",
    "PLMN: {\n",
    "    PLMN0: {\n",
    "           FULLNAME=\"OpenAirInterface\";\n",
    "           SHORTNAME=\"OAICN\";\n",
    "           MNC=\"96\";\n",
    "           MCC=\"208\";\n",
    "    };\n",
    "};\n",
    "\n",
    "UE0:\n",
    "{\n",
    "    USER: {\n",
    "        IMEI=\"356113022094149\";\n",
    "        MANUFACTURER=\"OAI\";\n",
    "        MODEL=\"LTE SoftModem\";\n",
    "        PIN=\"0000\";\n",
    "    };\n",
    "\n",
    "    SIM: {\n",
    "        MSIN=\"0100000001\";\n",
    "        USIM_API_K=\"fec86ba6eb707ed08905757b1bb44b8f\";\n",
    "        OPC=\"c42449363bbad02b66d16bc975d77cc1\";\n",
    "        MSISDN=\"001011234561010\";\n",
    "    };\n",
    "\n",
    "    # Home PLMN Selector with Access Technology\n",
    "    HPLMN= \"20896\";\n",
    "\n",
    "    # User controlled PLMN Selector with Access Technology\n",
    "    UCPLMN_LIST = ();\n",
    "\n",
    "    # Operator PLMN List\n",
    "    OPLMN_LIST = (\"20896\");\n",
    "\n",
    "    # Operator controlled PLMN Selector with Access Technology\n",
    "    OCPLMN_LIST = ();\n",
    "\n",
    "    # Forbidden plmns\n",
    "    FPLMN_LIST = ();\n",
    "\n",
    "    # Equivalent home plmns\n",
    "    EHPLMN_LIST = ();\n",
    "\n",
    "};\n",
    "\n",
    "UE1:\n",
    "{\n",
    "    USER: {\n",
    "        IMEI=\"356113022094149\";\n",
    "        MANUFACTURER=\"OAI\";\n",
    "        MODEL=\"LTE SoftModem\";\n",
    "        PIN=\"0000\";\n",
    "    };\n",
    "\n",
    "    SIM: {\n",
    "        MSIN=\"0100000001\";\n",
    "        USIM_API_K=\"fec86ba6eb707ed08905757b1bb44b8f\";\n",
    "        OPC=\"c42449363bbad02b66d16bc975d77cc1\";\n",
    "        MSISDN=\"001011234561010\";\n",
    "    };\n",
    "\n",
    "    # Home PLMN Selector with Access Technology\n",
    "    HPLMN= \"20896\";\n",
    "\n",
    "    # User controlled PLMN Selector with Access Technology\n",
    "    UCPLMN_LIST = ();\n",
    "\n",
    "    # Operator PLMN List\n",
    "    OPLMN_LIST = (\"20896\");\n",
    "\n",
    "    # Operator controlled PLMN Selector with Access Technology\n",
    "    OCPLMN_LIST = ();\n",
    "\n",
    "    # Forbidden plmns\n",
    "    FPLMN_LIST = ();\n",
    "\n",
    "    # Equivalent home plmns\n",
    "    EHPLMN_LIST = ();\n",
    "\n",
    "};\n",
    "\n",
    "UE2:\n",
    "{\n",
    "    USER: {\n",
    "        IMEI=\"356113022094149\";\n",
    "        MANUFACTURER=\"OAI\";\n",
    "        MODEL=\"LTE SoftModem\";\n",
    "        PIN=\"0000\";\n",
    "    };\n",
    "\n",
    "    SIM: {\n",
    "        MSIN=\"0100000001\";\n",
    "        USIM_API_K=\"fec86ba6eb707ed08905757b1bb44b8f\";\n",
    "        OPC=\"c42449363bbad02b66d16bc975d77cc1\";\n",
    "        MSISDN=\"001011234561010\";\n",
    "    };\n",
    "\n",
    "    # Home PLMN Selector with Access Technology\n",
    "    HPLMN= \"20896\";\n",
    "\n",
    "    # User controlled PLMN Selector with Access Technology\n",
    "    UCPLMN_LIST = ();\n",
    "\n",
    "    # Operator PLMN List\n",
    "    OPLMN_LIST = (\"20896\");\n",
    "\n",
    "    # Operator controlled PLMN Selector with Access Technology\n",
    "    OCPLMN_LIST = ();\n",
    "\n",
    "    # Forbidden plmns\n",
    "    FPLMN_LIST = ();\n",
    "\n",
    "    # Equivalent home plmns\n",
    "    EHPLMN_LIST = ();\n",
    "\n",
    "};\n",
    "\n",
    "UE3:\n",
    "{\n",
    "    USER: {\n",
    "        IMEI=\"356113022094149\";\n",
    "        MANUFACTURER=\"OAI\";\n",
    "        MODEL=\"LTE SoftModem\";\n",
    "        PIN=\"0000\";\n",
    "    };\n",
    "\n",
    "    SIM: {\n",
    "        MSIN=\"0100000001\";\n",
    "        USIM_API_K=\"fec86ba6eb707ed08905757b1bb44b8f\";\n",
    "        OPC=\"c42449363bbad02b66d16bc975d77cc1\";\n",
    "        MSISDN=\"001011234561010\";\n",
    "    };\n",
    "\n",
    "    # Home PLMN Selector with Access Technology\n",
    "    HPLMN= \"20896\";\n",
    "\n",
    "    # User controlled PLMN Selector with Access Technology\n",
    "    UCPLMN_LIST = ();\n",
    "\n",
    "    # Operator PLMN List\n",
    "    OPLMN_LIST = (\"20896\");\n",
    "\n",
    "    # Operator controlled PLMN Selector with Access Technology\n",
    "    OCPLMN_LIST = ();\n",
    "\n",
    "    # Forbidden plmns\n",
    "    FPLMN_LIST = ();\n",
    "\n",
    "    # Equivalent home plmns\n",
    "    EHPLMN_LIST = ();\n",
    "\n",
    "};\n",
    "\n",
    "```\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "####  Step 3:\n",
    "- Adjusting the `conf2uedata.txt` file\n",
    "\n",
    "```bash\n",
    "cd /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/\n",
    "cp conf2uedata.txt conf2uedata_original.txt\n",
    "rm -rf conf2uedata.txt\n",
    "vi conf2uedata.txt  \n",
    "```\n",
    "\n",
    "- After copying we will have the following files\n",
    "\n",
    "![UE_conf2uedata_config_](../FIGS/H04_4G_EPC_UNI_III/4G_EPC_CP_conf2uedata.png)\n",
    "\n",
    "- In this step you need to edit the `conf2uedata.txt` file as follows\n",
    "\n",
    "⚠️⚠️⚠️ **Attention:** Note that in the file `conf2uedata.txt` the path “/home/dco1020/openairinterface5g/cmake_targets/ran_build/build/” refers to the location of the files needed for the UE to work. In this case, it's important to check that the path actually exists! In general, we only need to check the beginning of the path `/home/dco1020` and replace all its occurrences in the file `conf2uedata.txt`.\n",
    "\n",
    "---\n",
    "```bash\n",
    "\n",
    "UE's non-volatile data:\n",
    "\n",
    "IMEI\t\t= 356113022094149\n",
    "manufacturer\t= OAI\n",
    "model\t\t= LTE SoftModem\n",
    "PIN\t\t= 0000\n",
    "UE identity data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue.nvram0\n",
    "\n",
    "EMM non-volatile data:\n",
    "\n",
    "IMSI\t\t= 208.960.100000001\n",
    "RPLMN\t\t= 20896\n",
    "EPS Mobility Management data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue_emm.nvram0\n",
    "\n",
    "UE's non-volatile data:\n",
    "\n",
    "IMEI\t\t= 356113022094149\n",
    "manufacturer\t= OAI\n",
    "model\t\t= LTE SoftModem\n",
    "PIN\t\t= 0000\n",
    "UE identity data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue.nvram1\n",
    "\n",
    "EMM non-volatile data:\n",
    "\n",
    "IMSI\t\t= 208.960.100000001\n",
    "RPLMN\t\t= 20896\n",
    "EPS Mobility Management data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue_emm.nvram1\n",
    "\n",
    "UE's non-volatile data:\n",
    "\n",
    "IMEI\t\t= 356113022094149\n",
    "manufacturer\t= OAI\n",
    "model\t\t= LTE SoftModem\n",
    "PIN\t\t= 0000\n",
    "UE identity data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue.nvram2\n",
    "\n",
    "EMM non-volatile data:\n",
    "\n",
    "IMSI\t\t= 208.960.100000001\n",
    "RPLMN\t\t= 20896\n",
    "EPS Mobility Management data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue_emm.nvram2\n",
    "\n",
    "UE's non-volatile data:\n",
    "\n",
    "IMEI\t\t= 356113022094149\n",
    "manufacturer\t= OAI\n",
    "model\t\t= LTE SoftModem\n",
    "PIN\t\t= 0000\n",
    "UE identity data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue.nvram3\n",
    "\n",
    "EMM non-volatile data:\n",
    "\n",
    "IMSI\t\t= 208.960.100000001\n",
    "RPLMN\t\t= 20896\n",
    "EPS Mobility Management data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.ue_emm.nvram3\n",
    "\n",
    "USIM data:\n",
    "\n",
    "Administrative Data:\n",
    "\tUE_Operation_Mode\t= 0x00\n",
    "\tAdditional_Info\t\t= 0xffff\n",
    "\tMNC_Length\t\t= 2\n",
    "\n",
    "IMSI:\n",
    "\tlength\t= 8\n",
    "\tparity\t= Odd\n",
    "\tdigits\t= 15\n",
    "\tdigits\t= 208960100000001\n",
    "\n",
    "Ciphering and Integrity Keys:\n",
    "\tKSI\t: 0x07\n",
    "\tCK\t: \"\"\n",
    "\tIK\t: \"\"\n",
    "\n",
    "\tusim_api_k: fe c8 6b a6 eb 70 7e d0 89 05 75 7b 1b b4 4b 8f\n",
    "\topc       : c4 24 49 36 3b ba d0 2b 66 d1 6b c9 75 d7 7c c1\n",
    "\n",
    "EPS NAS security context:\n",
    "\tKSIasme\t: 0x07\n",
    "\tKasme\t: \"\"\n",
    "\talgorithmID\t: 0x02\n",
    "\n",
    "MSISDN\t= 001 0112 3456\n",
    "\n",
    "PNN[0]\t= {OpenAirInterfaceEOAICN, OAICN}\n",
    "PNN[1]\t= {, }\n",
    "PNN[2]\t= {, }\n",
    "PNN[3]\t= {, }\n",
    "PNN[4]\t= {, }\n",
    "PNN[5]\t= {, }\n",
    "PNN[6]\t= {, }\n",
    "PNN[7]\t= {, }\n",
    "\n",
    "OPL[0]\t= 20896, TAC = [0001 - fffd], record_id = 0\n",
    "OPL[1]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[2]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[3]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[4]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[5]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[6]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[7]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "\n",
    "HPLMN\t\t= 20896, AcT = 0x80c0\n",
    "\n",
    "FPLMN[0]\t= \n",
    "FPLMN[1]\t= \n",
    "FPLMN[2]\t= \n",
    "FPLMN[3]\t= \n",
    "\n",
    "EHPLMN[0]\t= \n",
    "EHPLMN[1]\t= \n",
    "\n",
    "PLMN[0]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[1]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[2]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[3]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[4]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[5]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[6]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[7]\t\t= , AcTPLMN = 0x0\n",
    "\n",
    "OPLMN[0]\t= , AcTPLMN = 0x0\n",
    "OPLMN[1]\t= , AcTPLMN = 0x0\n",
    "OPLMN[2]\t= , AcTPLMN = 0x0\n",
    "OPLMN[3]\t= , AcTPLMN = 0x0\n",
    "OPLMN[4]\t= , AcTPLMN = 0x0\n",
    "OPLMN[5]\t= , AcTPLMN = 0x0\n",
    "OPLMN[6]\t= , AcTPLMN = 0x0\n",
    "OPLMN[7]\t= , AcTPLMN = 0x0\n",
    "\n",
    "HPPLMN\t\t= 0x00 (0 minutes)\n",
    "\n",
    "LOCI:\n",
    "\tTMSI = 0x000d\n",
    "\tLAI\t: PLMN = 20896, LAC = 0xfffe\n",
    "\tstatus\t= 1\n",
    "\n",
    "PSLOCI:\n",
    "\tP-TMSI = 0x000d\n",
    "\tsignature = 0x1 0x2 0x3\n",
    "\tRAI\t: PLMN = 20896, LAC = 0xfffe, RAC = 0x1\n",
    "\tstatus\t= 1\n",
    "\n",
    "EPSLOCI:\n",
    "\tGUTI\t: GUMMEI\t: (PLMN = 20896, MMEgid = 0x102, MMEcode = 0xf), M-TMSI = 0x000d\n",
    "\tTAI\t: PLMN = 20896, TAC = 0x01\n",
    "\tstatus\t= 0\n",
    "\n",
    "NASCONFIG:\n",
    "\tNAS_SignallingPriority\t\t: 0x00\n",
    "\tNMO_I_Behaviour\t\t\t: 0x00\n",
    "\tAttachWithImsi\t\t\t: 0x01\n",
    "\tMinimumPeriodicSearchTimer\t: 0x00\n",
    "\tExtendedAccessBarring\t\t: 0x00\n",
    "\tTimer_T3245_Behaviour\t\t: 0x00\n",
    "USIM data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.usim.nvram0\n",
    "\n",
    "USIM data:\n",
    "\n",
    "Administrative Data:\n",
    "\tUE_Operation_Mode\t= 0x00\n",
    "\tAdditional_Info\t\t= 0xffff\n",
    "\tMNC_Length\t\t= 2\n",
    "\n",
    "IMSI:\n",
    "\tlength\t= 8\n",
    "\tparity\t= Odd\n",
    "\tdigits\t= 15\n",
    "\tdigits\t= 208960100000001\n",
    "\n",
    "Ciphering and Integrity Keys:\n",
    "\tKSI\t: 0x07\n",
    "\tCK\t: \"\"\n",
    "\tIK\t: \"\"\n",
    "\n",
    "\tusim_api_k: fe c8 6b a6 eb 70 7e d0 89 05 75 7b 1b b4 4b 8f\n",
    "\topc       : c4 24 49 36 3b ba d0 2b 66 d1 6b c9 75 d7 7c c1\n",
    "\n",
    "EPS NAS security context:\n",
    "\tKSIasme\t: 0x07\n",
    "\tKasme\t: \"\"\n",
    "\talgorithmID\t: 0x02\n",
    "\n",
    "MSISDN\t= 001 0112 3456\n",
    "\n",
    "PNN[0]\t= {OpenAirInterfaceEOAICN, OAICN}\n",
    "PNN[1]\t= {, }\n",
    "PNN[2]\t= {, }\n",
    "PNN[3]\t= {, }\n",
    "PNN[4]\t= {, }\n",
    "PNN[5]\t= {, }\n",
    "PNN[6]\t= {, }\n",
    "PNN[7]\t= {, }\n",
    "\n",
    "OPL[0]\t= 20896, TAC = [0001 - fffd], record_id = 0\n",
    "OPL[1]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[2]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[3]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[4]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[5]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[6]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[7]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "\n",
    "HPLMN\t\t= 20896, AcT = 0x80c0\n",
    "\n",
    "FPLMN[0]\t= \n",
    "FPLMN[1]\t= \n",
    "FPLMN[2]\t= \n",
    "FPLMN[3]\t= \n",
    "\n",
    "EHPLMN[0]\t= \n",
    "EHPLMN[1]\t= \n",
    "\n",
    "PLMN[0]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[1]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[2]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[3]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[4]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[5]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[6]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[7]\t\t= , AcTPLMN = 0x0\n",
    "\n",
    "OPLMN[0]\t= , AcTPLMN = 0x0\n",
    "OPLMN[1]\t= , AcTPLMN = 0x0\n",
    "OPLMN[2]\t= , AcTPLMN = 0x0\n",
    "OPLMN[3]\t= , AcTPLMN = 0x0\n",
    "OPLMN[4]\t= , AcTPLMN = 0x0\n",
    "OPLMN[5]\t= , AcTPLMN = 0x0\n",
    "OPLMN[6]\t= , AcTPLMN = 0x0\n",
    "OPLMN[7]\t= , AcTPLMN = 0x0\n",
    "\n",
    "HPPLMN\t\t= 0x00 (0 minutes)\n",
    "\n",
    "LOCI:\n",
    "\tTMSI = 0x000d\n",
    "\tLAI\t: PLMN = 20896, LAC = 0xfffe\n",
    "\tstatus\t= 1\n",
    "\n",
    "PSLOCI:\n",
    "\tP-TMSI = 0x000d\n",
    "\tsignature = 0x1 0x2 0x3\n",
    "\tRAI\t: PLMN = 20896, LAC = 0xfffe, RAC = 0x1\n",
    "\tstatus\t= 1\n",
    "\n",
    "EPSLOCI:\n",
    "\tGUTI\t: GUMMEI\t: (PLMN = 20896, MMEgid = 0x102, MMEcode = 0xf), M-TMSI = 0x000d\n",
    "\tTAI\t: PLMN = 20896, TAC = 0x01\n",
    "\tstatus\t= 0\n",
    "\n",
    "NASCONFIG:\n",
    "\tNAS_SignallingPriority\t\t: 0x00\n",
    "\tNMO_I_Behaviour\t\t\t: 0x00\n",
    "\tAttachWithImsi\t\t\t: 0x01\n",
    "\tMinimumPeriodicSearchTimer\t: 0x00\n",
    "\tExtendedAccessBarring\t\t: 0x00\n",
    "\tTimer_T3245_Behaviour\t\t: 0x00\n",
    "USIM data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.usim.nvram1\n",
    "\n",
    "USIM data:\n",
    "\n",
    "Administrative Data:\n",
    "\tUE_Operation_Mode\t= 0x00\n",
    "\tAdditional_Info\t\t= 0xffff\n",
    "\tMNC_Length\t\t= 2\n",
    "\n",
    "IMSI:\n",
    "\tlength\t= 8\n",
    "\tparity\t= Odd\n",
    "\tdigits\t= 15\n",
    "\tdigits\t= 208960100000001\n",
    "\n",
    "Ciphering and Integrity Keys:\n",
    "\tKSI\t: 0x07\n",
    "\tCK\t: \"\"\n",
    "\tIK\t: \"\"\n",
    "\n",
    "\tusim_api_k: fe c8 6b a6 eb 70 7e d0 89 05 75 7b 1b b4 4b 8f\n",
    "\topc       : c4 24 49 36 3b ba d0 2b 66 d1 6b c9 75 d7 7c c1\n",
    "\n",
    "EPS NAS security context:\n",
    "\tKSIasme\t: 0x07\n",
    "\tKasme\t: \"\"\n",
    "\talgorithmID\t: 0x02\n",
    "\n",
    "MSISDN\t= 001 0112 3456\n",
    "\n",
    "PNN[0]\t= {OpenAirInterfaceEOAICN, OAICN}\n",
    "PNN[1]\t= {, }\n",
    "PNN[2]\t= {, }\n",
    "PNN[3]\t= {, }\n",
    "PNN[4]\t= {, }\n",
    "PNN[5]\t= {, }\n",
    "PNN[6]\t= {, }\n",
    "PNN[7]\t= {, }\n",
    "\n",
    "OPL[0]\t= 20896, TAC = [0001 - fffd], record_id = 0\n",
    "OPL[1]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[2]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[3]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[4]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[5]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[6]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[7]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "\n",
    "HPLMN\t\t= 20896, AcT = 0x80c0\n",
    "\n",
    "FPLMN[0]\t= \n",
    "FPLMN[1]\t= \n",
    "FPLMN[2]\t= \n",
    "FPLMN[3]\t= \n",
    "\n",
    "EHPLMN[0]\t= \n",
    "EHPLMN[1]\t= \n",
    "\n",
    "PLMN[0]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[1]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[2]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[3]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[4]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[5]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[6]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[7]\t\t= , AcTPLMN = 0x0\n",
    "\n",
    "OPLMN[0]\t= , AcTPLMN = 0x0\n",
    "OPLMN[1]\t= , AcTPLMN = 0x0\n",
    "OPLMN[2]\t= , AcTPLMN = 0x0\n",
    "OPLMN[3]\t= , AcTPLMN = 0x0\n",
    "OPLMN[4]\t= , AcTPLMN = 0x0\n",
    "OPLMN[5]\t= , AcTPLMN = 0x0\n",
    "OPLMN[6]\t= , AcTPLMN = 0x0\n",
    "OPLMN[7]\t= , AcTPLMN = 0x0\n",
    "\n",
    "HPPLMN\t\t= 0x00 (0 minutes)\n",
    "\n",
    "LOCI:\n",
    "\tTMSI = 0x000d\n",
    "\tLAI\t: PLMN = 20896, LAC = 0xfffe\n",
    "\tstatus\t= 1\n",
    "\n",
    "PSLOCI:\n",
    "\tP-TMSI = 0x000d\n",
    "\tsignature = 0x1 0x2 0x3\n",
    "\tRAI\t: PLMN = 20896, LAC = 0xfffe, RAC = 0x1\n",
    "\tstatus\t= 1\n",
    "\n",
    "EPSLOCI:\n",
    "\tGUTI\t: GUMMEI\t: (PLMN = 20896, MMEgid = 0x102, MMEcode = 0xf), M-TMSI = 0x000d\n",
    "\tTAI\t: PLMN = 20896, TAC = 0x01\n",
    "\tstatus\t= 0\n",
    "\n",
    "NASCONFIG:\n",
    "\tNAS_SignallingPriority\t\t: 0x00\n",
    "\tNMO_I_Behaviour\t\t\t: 0x00\n",
    "\tAttachWithImsi\t\t\t: 0x01\n",
    "\tMinimumPeriodicSearchTimer\t: 0x00\n",
    "\tExtendedAccessBarring\t\t: 0x00\n",
    "\tTimer_T3245_Behaviour\t\t: 0x00\n",
    "USIM data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.usim.nvram2\n",
    "\n",
    "USIM data:\n",
    "\n",
    "Administrative Data:\n",
    "\tUE_Operation_Mode\t= 0x00\n",
    "\tAdditional_Info\t\t= 0xffff\n",
    "\tMNC_Length\t\t= 2\n",
    "\n",
    "IMSI:\n",
    "\tlength\t= 8\n",
    "\tparity\t= Odd\n",
    "\tdigits\t= 15\n",
    "\tdigits\t= 208960100000001\n",
    "\n",
    "Ciphering and Integrity Keys:\n",
    "\tKSI\t: 0x07\n",
    "\tCK\t: \"\"\n",
    "\tIK\t: \"\"\n",
    "\n",
    "\tusim_api_k: fe c8 6b a6 eb 70 7e d0 89 05 75 7b 1b b4 4b 8f\n",
    "\topc       : c4 24 49 36 3b ba d0 2b 66 d1 6b c9 75 d7 7c c1\n",
    "\n",
    "EPS NAS security context:\n",
    "\tKSIasme\t: 0x07\n",
    "\tKasme\t: \"\"\n",
    "\talgorithmID\t: 0x02\n",
    "\n",
    "MSISDN\t= 001 0112 3456\n",
    "\n",
    "PNN[0]\t= {OpenAirInterfaceEOAICN, OAICN}\n",
    "PNN[1]\t= {, }\n",
    "PNN[2]\t= {, }\n",
    "PNN[3]\t= {, }\n",
    "PNN[4]\t= {, }\n",
    "PNN[5]\t= {, }\n",
    "PNN[6]\t= {, }\n",
    "PNN[7]\t= {, }\n",
    "\n",
    "OPL[0]\t= 20896, TAC = [0001 - fffd], record_id = 0\n",
    "OPL[1]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[2]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[3]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[4]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[5]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[6]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "OPL[7]\t= , TAC = [0000 - 0000], record_id = 0\n",
    "\n",
    "HPLMN\t\t= 20896, AcT = 0x80c0\n",
    "\n",
    "FPLMN[0]\t= \n",
    "FPLMN[1]\t= \n",
    "FPLMN[2]\t= \n",
    "FPLMN[3]\t= \n",
    "\n",
    "EHPLMN[0]\t= \n",
    "EHPLMN[1]\t= \n",
    "\n",
    "PLMN[0]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[1]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[2]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[3]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[4]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[5]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[6]\t\t= , AcTPLMN = 0x0\n",
    "PLMN[7]\t\t= , AcTPLMN = 0x0\n",
    "\n",
    "OPLMN[0]\t= , AcTPLMN = 0x0\n",
    "OPLMN[1]\t= , AcTPLMN = 0x0\n",
    "OPLMN[2]\t= , AcTPLMN = 0x0\n",
    "OPLMN[3]\t= , AcTPLMN = 0x0\n",
    "OPLMN[4]\t= , AcTPLMN = 0x0\n",
    "OPLMN[5]\t= , AcTPLMN = 0x0\n",
    "OPLMN[6]\t= , AcTPLMN = 0x0\n",
    "OPLMN[7]\t= , AcTPLMN = 0x0\n",
    "\n",
    "HPPLMN\t\t= 0x00 (0 minutes)\n",
    "\n",
    "LOCI:\n",
    "\tTMSI = 0x000d\n",
    "\tLAI\t: PLMN = 20896, LAC = 0xfffe\n",
    "\tstatus\t= 1\n",
    "\n",
    "PSLOCI:\n",
    "\tP-TMSI = 0x000d\n",
    "\tsignature = 0x1 0x2 0x3\n",
    "\tRAI\t: PLMN = 20896, LAC = 0xfffe, RAC = 0x1\n",
    "\tstatus\t= 1\n",
    "\n",
    "EPSLOCI:\n",
    "\tGUTI\t: GUMMEI\t: (PLMN = 20896, MMEgid = 0x102, MMEcode = 0xf), M-TMSI = 0x000d\n",
    "\tTAI\t: PLMN = 20896, TAC = 0x01\n",
    "\tstatus\t= 0\n",
    "\n",
    "NASCONFIG:\n",
    "\tNAS_SignallingPriority\t\t: 0x00\n",
    "\tNMO_I_Behaviour\t\t\t: 0x00\n",
    "\tAttachWithImsi\t\t\t: 0x01\n",
    "\tMinimumPeriodicSearchTimer\t: 0x00\n",
    "\tExtendedAccessBarring\t\t: 0x00\n",
    "\tTimer_T3245_Behaviour\t\t: 0x00\n",
    "USIM data file: /home/dco1020/openairinterface5g/cmake_targets/ran_build/build/.usim.nvram3\n",
    "```\n",
    "___\n",
    "\n",
    "- After saving the `conf2uedata.txt` file, you need to reinstall the UE dependencies\n",
    "\n",
    "```bash\n",
    "cd ../..\n",
    "sudo ./build_oai -w USRP --UE --build-lib \"uescope\"\n",
    "```\n",
    "\n",
    "- After finishing the UE build you can run `lte-uesoftmodem`\n",
    "\n",
    "```bash\n",
    "cd ran_build/build/\n",
    "sudo -E ./lte-uesoftmodem --rfsim -C 2680000000 -r 25 --ue-rxgain 140 --ue-txgain 120 --rfsimulator.serveraddr 192.168.61.20 --log_config.global_log_options level,nocolor,time -O ../../../ci-scripts/conf_files/lteue.usim-ci.conf\n",
    "```\n",
    "\n",
    "- If everything went well, the following result is expected \n",
    "\n",
    "![UE_conf2uedata_config_](../FIGS/H04_4G_EPC_UNI_III/4G_EPC_UE_rfsim1.png)\n",
    "\n",
    "![UE_conf2uedata_config_](../FIGS/H04_4G_EPC_UNI_III/4G_EPC_UE_rfsim2.png)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
